﻿using Zenject;
using UnityEngine;
using System.Collections.Generic;

namespace DiIoc.Factory
{   
    /// <summary>
    /// we have a enemy manager response to manager all enemies
    /// </summary>
    public class EnemyManager
    {
        public List<Enemy> Enemies { get; private set; } = new List<Enemy>();
        public void RegisterEnemy(Enemy enemy)
        {
            Enemies.Add(enemy);
            Debug.Log($"we have {Enemies.Count} enemies spwaned");
        }
    }
    /// <summary>
    /// this is a simple class to randomly created enemies
    /// </summary>
    public class EnemySpawner : ITickable
    {
        readonly Enemy.Factory _enemyFactory;

        public EnemySpawner(Enemy.Factory enemyFactory)
        {
            _enemyFactory = enemyFactory;
        }
        public void Tick()
        {
            var randomNum = Random.Range(1, 100);
            if (randomNum > 50)
            {
                var enemy = _enemyFactory.Create();
                enemy.gameObject.transform.position = Random.insideUnitSphere * 10;
            }
        }
    }


}

